var a, e = require("../../@babel/runtime/helpers/defineProperty"), t = getApp(), o = require("../../model/douyinModel.js"), s = require("../../model/awconfig.js"), i = require("../../utils/util.js"), n = require("../../ui/dist/base/index").$Toast;
function getUrl(str) {
    const reg = /(https?|http|ftp|file):\/\/[-A-Za-z0-9+&@#/%?=~_|!:,.;]+[-A-Za-z0-9+&@#/%=~_|]/g;
    const strValue = str.match(reg);
    if (strValue && strValue.length > 0) {
      return strValue[0];
    }
    return null;
  }
Page({
    data: (a = {
        modeAD: i.modeAD(),
        showHover: !0,
        dyPHost: t.globalData.host,
        downloadHosts: [],
        showGongZhongHaoBottom: t.globalData.showGongZhongHaoBottom,
        ff: 500,
        localShowBannerAD: 1,
        tempAD: 1,
        kItems: t.globalData.adKeyHome + ";" + t.globalData.adKeyDYDownload,
        fMod: 5,
        showVideoBanner: 1,
        videoBL: 0,
        videoADLimit: 1e3,
        interstitialDT: 1e4,
        interstitialDT2: 1e4,
        interstitialMod: 5,
        onShowCount: 0,
        adBannerType: 1,
        adBannerTypeHome: 1,
        videoId:t.globalData.videoId,
        adKeyHome: t.globalData.adKeyHome,
        adKeyDYDownload: t.globalData.adKeyDYDownload,
        adKeyDYVideoInfo: t.globalData.adKeyDYVideoInfo,
        adKeyDYMusic: t.globalData.adKeyDYMusic,
        adKeyUserInifo: t.globalData.adKeyUserInifo,
        adKeyKSDownload: t.globalData.adKeyKSDownload,
        adKeyAlert: t.globalData.adKeyAlert,
        adKeyMore: t.globalData.adKeyMore,
        adKeyWater: t.globalData.adKeyWater,
        adRewardedVideo1: t.globalData.jili,
        adInterstitialDYD: t.globalData.chaping,
        adVideoBanner2: t.globalData.adVideoBanner2,
        ad_mode_banner_2: t.globalData.ad_mode_banner_2,
        ad_mode_hover2: t.globalData.ad_mode_hover2,
        permissionText: "保存内容到相册，需要相册权限，请开启权限",
        aSTips: "成功保存到手机，保存位置请看屏幕提示",
        iSTips: "成功保存到手机相册",
        openCustomer: 0,
        customerTitle: "客服",
        bottomMessage: "视频及图片归平台及作者所有，本工具不存储任何视频及图片",
        parsedPlayVideo: 0,
        adBannerInfo: {
            width: 720,
            height: 0
        },
        albumTips: "保存视频到手机需要打开相册权限，请在更多页面中设置允许打开。",
        douyinVideoActionTips: "注意：如果下载视频失败或太慢，请复制无水印链接，用电脑浏览器下载",
        errorTips: "解析失败，请换个网络试试或者联系客服咨询",
        inputTopTips: "解析成功后会出现下载按钮",
        showAlertAD: 0,
        openShare: 1,
        shareTips: "免费工具，觉得好用，支持作者，推荐给好友吧",
        shareGroupText: "推荐小程序到微信群",
        shareTimeLineText: "获取推荐的二维码图",
        openShareLimit: 0,
        shareLimitTips: "请您先分享小程序到微信群。分享到不同微信群，24小时内无限制使用。点击界面底部绿色按钮“分享小程序到微信群”按钮进行分享。谢谢支持~",
        openRewardedVideoAd: 0,
        openParseCountRVAD: 0,
        parseCountLimitTips: "您已经解析{0}次了，工具免费，麻烦您看完一个广告视频，支持下我们。我们将提供更好的服务。",
        parseCountLimitCancelText: "下次再说",
        parseCountLimit: 5,
        rewardedVideoAdTips: "下载视频需要您看完广告视频。看完一次广告视频24小时内无限制下载。",
        showDownloadProgressAD: 0,
        showDownloadProgressModel: !1,
        progressTitle: "视频下载中，请耐心等待",
        progressDesc: "工具永久免费，不限次数",
        parseSTips: "解析成功，点击下载无水印视频，直接保存视频到手机",
        expiredTime: "",
        isShare: !1,
        showModal: !1,
        showCopyTips: !1,
        parseBtnText: "解析",
        downloadVideoBtnText: "下载视频",
        downloadVideoDisabled: !1,
        downloadImageBtnText: "下载视频封面",
        downloadImageDisabled: !1,
        queryBtnText: "查询",
        isLoading: !1,
        config:wx.getStorageSync('appConfig'),
        parseVideoUrl: "",
        parseVideoResult: null,
        videoPlayURL: null
    }, e(a, "parseVideoResult", null), e(a, "parseQueryUrl", ""), e(a, "queryUserResult", null), 
    e(a, "parseMusicBtnText", "解析"), e(a, "copyMusicLinkText", "下载背景音"), e(a, "parseMusicResult", null), 
    e(a, "hostFlag", "2"), e(a, "adBannerImageURL", ""), e(a, "adBannerWidth", 600), 
    e(a, "adBannerHeight", 200), e(a, "adBannerType", 3), e(a, "showDYDAlertAD", 0), 
    e(a, "showTimeLine", 0), e(a, "downloadErrorMsg", "服务器错误，请截图，然后点击联系客服反馈问题。"), e(a, "adAppID", "wx5ad29a508715a79d"), 
    e(a, "adBannerPath", "pages/index/index"), e(a, "list", [ {
        id: "parseVideo",
        name: "短视频去水印",
        open: !0
    } ]), e(a, "list_tools", [ {
        title: "使用教程",
        name: "icon",
        color: "white",
        icon: "",
        app_id: "wx4ed902e153b35e79",
        url: "/pages/tutorialImages/tutorialImages"
    }, {
        title: "常见问题",
        name: "layout",
        color: "white",
        icon: "",
        url: "/pages/question/question"
    } ]), a),
    onLoad: function(a) {
        var e = this;
        e.setData({
            navTitle: getApp().globalData.appDisplayName
        });
        var t = a.isShare;
        null == t && (t = 0);
        var o = a.type;
        null == o && (o = "parseVideo"), console.log(a);
        var n = [], d = {}, l = wx.getStorageSync("currentItem");
        null != l && l.length > 0 ? ((d = JSON.parse(decodeURI(l))).open = !0, d.id = o, 
        n[0] = d) : (d.type = "parseKSVideo", d.title = "全网免费去水印", d.desc = "全网免费去水印", d.icon = "../../images/dou.jpg", 
        d.open = !0, d.id = "parseVideo", n[0] = d);
        e.setData({
            isShare: t,
            inputVideoTxt: "",
            inputMusicTxt: "",
            type: o,
            list: n
        }), e.setupVideoAD(),s.registerConfigCallback(function() {
            e.awconfigSuccessCallback(1);
        }, function(a) {}), e.awconfigSuccessCallback(0), 1 != e.data.openRewardedVideoAd && 1 != e.data.openParseCountRVAD || setTimeout(function() {
            
        }, 500);
        var r = null;
        wx.createInterstitialAd && ((r = wx.createInterstitialAd({
            adUnitId: e.data.adInterstitialDYD
        })).onLoad(function() {}), r.onError(function(a) {}), r.onClose(function() {})), 
        e.setData({
            interstitialAd: r
        }), i.checkUpdateAPP();
    },
    awconfigSuccessCallback: function(a) {
        var e = wx.getStorageSync("appConfig"), t = this.data.dyPHost;
        null != e.dyPHost && e.dyPHost.length > 0 && (t = e.dyPHost);
        var o = this.data.navTitle;
        null != e.navTitle && (o = e.navTitle);
        var s = this.data.permissionText;
        null != e.permissionText && (s = e.permissionText);
        var i = this.data.aSTips;
        null != e.aSTips && (i = e.aSTips);
        var n = this.data.iSTips;
        null != e.iSTips && (n = e.iSTips);
        var d = this.data.openCustomer;
        null != e.openCustomer && (d = e.openCustomer);
        var l = this.data.customerTitle;
        null != e.customerTitle && (l = e.customerTitle);
        var r = this.data.bottomMessage;
        null != e.bottomMessage && (r = e.bottomMessage);
        var u = this.data.parsedPlayVideo;
        null != e.parsedPlayVideo && (u = e.parsedPlayVideo);
        var p = this.data.adBannerInfo;
        null != e.adBannerInfo && (p = e.adBannerInfo);
        var h = this.data.hover;
        null != e.hover && (h = e.hover);
        this.data.albumTips;
        null != e.albumTips && e.albumTips;
        var c = this.data.openShare;
        null != e.openShare && (c = e.openShare);
        var w = this.data.shareTips;
        null != e.shareTips && (w = e.shareTips);
        var g = this.data.downloadHosts;
        null != e.downloadHosts && "" != e.downloadHosts && (g = e.downloadHosts.split(","));
        var T = this.data.douyinVideoActionTips;
        null != e.douyinVideoActionTips && (T = e.douyinVideoActionTips);
        var D = this.data.errorTips;
        null != e.errorTips && (D = e.errorTips);
        var m = this.data.inputTopTips;
        null != e.inputTopTips && (m = e.inputTopTips);
        var f = this.data.shareGroupText;
        null != e.shareGroupText && (f = e.shareGroupText);
        var x = this.data.shareTimeLineText;
        null != e.shareTimeLineText && (x = e.shareTimeLineText);
        var v = this.data.openShareLimit;
        null != e.openShareLimit && (v = e.openShareLimit);
        var V = this.data.shareLimitTips;
        null != e.shareLimitTips && (V = e.shareLimitTips);
        var y = this.data.openRewardedVideoAd;
        null != e.openRewardedVideoAd && (y = e.openRewardedVideoAd);
        var A = this.data.openParseCountRVAD;
        null != e.openParseCountRVAD && (A = e.openParseCountRVAD);
        var M = this.data.parseCountLimit;
        null != e.parseCountLimit && (M = e.parseCountLimit);
        var b = this.data.parseCountLimitTips;
        null != e.parseCountLimitTips && (b = e.parseCountLimitTips);
        var B = this.data.rewardedVideoAdTips;
        null != e.rewardedVideoAdTips && (B = e.rewardedVideoAdTips);
        var S = this.data.parseCountLimitCancelText;
        null != e.parseCountLimitCancelText && (S = e.parseCountLimitCancelText);
        var L = this.data.showAlertAD;
        null != e.showAlertAD && (L = e.showAlertAD);
        var P = this.data.showDownloadProgressAD;
        null != e.showDownloadProgressAD && (P = e.showDownloadProgressAD);
        var I = this.data.progressTitle;
        null != e.progressTitle && (I = e.progressTitle);
        var C = this.data.progressDesc;
        null != e.progressDesc && (C = e.progressDesc);
        var k = this.data.parseSTips;
        null != e.parseSTips && (k = e.parseSTips);
        var U = this.data.ff;
        null != e.ff && (U = e.ff);
        var R = this.data.localShowBannerAD;
        null != e.localShowBannerAD && (R = e.localShowBannerAD);
        var _ = this.data.kItems;
        null != e.kItems && (_ = e.kItems);
        var H = this.data.fMod;
        null != e.fMod && (H = e.fMod);
        var F = this.data.showVideoBanner;
        null != e.showVideoBanner && (F = e.showVideoBanner);
        var E = this.data.videoBL;
        null != e.videoBL && (E = e.videoBL);
        var K = this.data.videoADLimit;
        null != e.videoADLimit && (K = e.videoADLimit);
        var Y = this.data.adVideoBanner2;
        null != e.adVideoBanner2 && (Y = e.adVideoBanner2);
        var Q = this.data.ad_mode_banner_2;
        null != e.ad_mode_banner_2 && (Q = e.ad_mode_banner_2);
        var q = this.data.ad_mode_hover2;
        null != e.ad_mode_hover2 && (q = e.ad_mode_hover2);
        var G = this.data.adInterstitialDYD;
        null != e.adInterstitialDYD && (G = e.adInterstitialDYD);
        var W = this.data.interstitialDT;
        null != e.interstitialDT && (W = e.interstitialDT);
        var N = this.data.interstitialDT2;
        null != e.interstitialDT2 && (N = e.interstitialDT2);
        var j = this.data.interstitialMod;
        null != e.interstitialMod && (j = e.interstitialMod);
        var O = this.data.adBannerImageURL;
        null != e.adBannerImageURL && (O = e.adBannerImageURL);
        var Z = this.data.adBannerWidth;
        null != e.adBannerWidth && (Z = e.adBannerWidth);
        var J = this.data.adBannerHeight;
        null != e.adBannerHeight && (J = e.adBannerHeight);
        var $ = this.data.adBannerType;
        null != e.adBannerType && ($ = e.adBannerType);
        var z = this.data.showDYDAlertAD;
        null != e.showDYDAlertAD && (z = e.showDYDAlertAD);
        var X = this.data.adAppID;
        null != e.adAppID && (X = e.adAppID);
        var aa = this.data.adBannerPath;
        null != e.adBannerPath && (aa = e.adBannerPath);
        var ea = this.data.showTimeLine;
        null != e.showTimeLine && (ea = e.showTimeLine);
        var ta = this.data.showGongZhongHaoBottom;
        null != e.showGongZhongHaoBottom && (ta = e.showGongZhongHaoBottom);
        var oa = this.data.downloadErrorMsg;
        null != e.downloadErrorMsg && (oa = e.downloadErrorMsg), this.data.onShowCount < K ? (console.log("视频广告"), 
        F = 1) : (console.log("普通广告"), F = 0), this.setData({
            dyPHost: t,
            navTitle: o,
            permissionText: s,
            aSTips: i,
            iSTips: n,
            openCustomer: d,
            customerTitle: l,
            bottomMessage: r,
            parsedPlayVideo: u,
            adBannerInfo: p,
            hover: h,
            openShare: c,
            shareTips: w,
            downloadHosts: g,
            douyinVideoActionTips: T,
            errorTips: D,
            inputTopTips: m,
            shareGroupText: f,
            shareTimeLineText: x,
            openShareLimit: v,
            shareLimitTips: V,
            openRewardedVideoAd: y,
            openParseCountRVAD: A,
            parseCountLimit: M,
            parseCountLimitTips: b,
            rewardedVideoAdTips: B,
            parseCountLimitCancelText: S,
            showAlertAD: L,
            showDownloadProgressAD: P,
            progressTitle: I,
            progressDesc: C,
            parseSTips: k,
            ff: U,
            kItems: _,
            localShowBannerAD: R,
            fMod: H,
            showVideoBanner: F,
            videoBL: E,
            videoADLimit: K,
            adVideoBanner2: Y,
            ad_mode_banner_2: Q,
            ad_mode_hover2: q,
            adInterstitialDYD: G,
            interstitialDT: W,
            interstitialDT2: N,
            interstitialMod: j,
            adBannerImageURL: O,
            adBannerWidth: Z,
            adBannerHeight: J,
            adBannerType: $,
            showDYDAlertAD: z,
            adAppID: X,
            adBannerPath: aa,
            showTimeLine: ea,
            showGongZhongHaoBottom: ta,
            downloadErrorMsg: oa
        });
    },
    setupVideoAD: function() {
        var a = this, e = t.globalData.systemInfo.SDKVersion;
        // if (!(i.compareVersion(e, "2.6.0") < 0)) {
            var o = wx.createRewardedVideoAd({
                adUnitId: 'adunit-ce63d91002f85834'
            });
            o.onLoad(function() {
                a.setData({
                    videoADLoaded: !0
                });
            }), o.onError(function(e) {
                console.log(e), a.setData({
                    videoADLoaded: !1
                });
            }), o.onClose(function(a) {
                a && a.isEnded || void 0 === a ? wx.setStorageSync('ParseCount', 0):[] 
            }), a.setData({
                rewardedVideoAd: o
            });
        // }
    },
    onShow: function() {
        var a = this;
        if (a.setData({
            onShowCount: a.data.onShowCount + 1
        }), 0 == a.data.openShareLimit ? a.setData({
            expiredTime: ""
        }) : "" == i.getExpiredFormatTime("ExpiredTime") || "" != i.getExpiredFormatTime("ExpiredTime") && i.canMake("ExpiredTime") ? a.setData({
            expiredTime: "全天可使用"
        }) : a.setData({
            expiredTime: "您今天没有分享，限制使用。分享一次到微信群，全天无限制使用。"
        }), 1 == a.data.onShowCount || a.data.onShowCount % a.data.fMod == 0 ? (a.setData({
            tempAD: a.data.localShowBannerAD
        }), 1 == a.data.showVideoBanner && a.setData({
            ff: 0
        }), setTimeout(function() {
            a.setData({
                tempAD: 1,
                modeAD: i.modeAD(),
                adKeyDYDownload: i.rAK(a.data.kItems)
            });
        }, a.data.ff)) : a.setData({
            tempAD: 1
        }), a.data.onShowCount > a.data.videoADLimit ? a.setData({
            showVideoBanner: 0
        }) : a.setData({
            showVideoBanner: 1
        }), 1 == a.data.onShowCount || a.data.onShowCount % a.data.interstitialMod == 0) {
            var e = a.data.interstitialDT;
            1 == wx.getStorageSync("HadShowAlertAD") && (e = a.data.interstitialDT2), setTimeout(function() {
                a.data.interstitialAd && a.data.interstitialAd.show().catch(function(a) {
                    console.error(a);
                });
            }, e);
        }
    },
    onShareAppMessage: function() {
        return setTimeout(function() {
            console.log("分享成功"), i.setExpiredTimeStamp("ExpiredTime");
        }, 2e3), {
            title: "免费视频去水印下载",
            path: "/pages/index/index?type=" + this.data.type + "&isShare=1",
            success: function(a) {
                console.log("分享成功"), i.setExpiredTimeStamp("ExpiredTime");
            },
            fail: function(a) {}
        };
    },
    bindVideoInput: function(a) {
        this.setData({
            parseVideoUrl: a.detail.value
        });
    },
    bindQueryInput: function(a) {
        this.setData({
            parseQueryUrl: a.detail.value
        });
    },
    bindMusicInput: function(a) {
        this.setData({
            parseMusicQueryUrl: a.detail.value
        });
    },
    bindParseLink: function(a) {
        var e = this;
        wx.getClipboardData({
            success: function(a) {
                if (null != a && null != a && null != a.data && null != a.data && a.data.length > 0) {
                    var t = a.data;
                    console.log(t), e.setData({
                        inputVideoTxt: t,
                        inputQueryTxt: t,
                        inputMusicTxt: t,
                        parseVideoUrl: t,
                        parseQueryUrl: t,
                        parseMusicQueryUrl: t
                    });
                } else wx.showModal({
                    title: "提示",
                    showCancel: !1,
                    content: "粘贴失败，请检查粘贴板是否有链接 或者 视频APP复制视频链接"
                });
            }
        });
    },
    bindVideoParse: function(a) {
        var t = this;
        console.log(
            t.data.videoADLoaded, 1, t.data.openParseCountRVAD,0,i.isViewParseLimit(),i.getParseCount(),t.data.parseCountLimit
        )
        if (null != t.data.parseVideoUrl && "" != t.data.parseVideoUrl) if (i.getParseCount() >= t.data.parseCountLimit) {
            var o, s = t.data.parseCountLimitTips.format(t.data.parseCountLimit.toString());
            wx.showModal({
                title: "提示",
                type: "warning",
                content: '您已经解析5次了，工具免费，麻烦您看完一个广告视频，支持下我们。我们将提供更好的服务。',
                confirmText: "看广告",
                showCancel:false,
                cancelText: t.data.parseCountLimitCancelText,
                success(a){
                    a.confirm ? t.showRewardedVideoAd() : []
                }
            });
        } else t.parseVideo(); else wx.showToast({
            title: "请输入视频链接"
        });
    },
    bindDownloadVideo: function(a) {
        var e = this;
        if (null != e.data.parseVideoResult) if (0 == i.canMake("ExpiredTime") && 1 == e.data.openRewardedVideoAd && e.data.videoADLoaded) e.showRewardedVideoAdTips(); else {
            var t = e.data.parseVideoResult.mp4;
            if (null != t && null != t && "" != t) {
                var o = t.split("/");
                if (o.length >= 3 && o[2]) {
                    var s = o[2];
                    if (wx.reportAnalytics("dyhost", {
                        host: s
                    }), e.data.downloadHosts.indexOf(s) > -1) return e.downloadVideoV2(t), void e.setData({
                        hostFlag: "d"
                    });
                }
            }
            null != e.data.parseVideoResult.mp4 ? i.albumPermissionCheck(function() {
                e.setData({
                    progress: 1
                }), e.downloadVideo(t, 1);
            }, e.data.permissionText) : wx.showToast({
                title: "请先解析视频"
            });
        } else wx.showToast({
            title: "请先解析视频"
        });
    },
    bindCopyNoWaterURL: function(a) {
        if (null != this.data.parseVideoResult) {
            var e = this.data.parseVideoResult.realDownloadURL;
            null != e && null != e && "" != e ? wx.setClipboardData({
                data: e,
                success: function(a) {
                    wx.showToast({
                        title: "复制成功"
                    });
                }
            }) : wx.showToast({
                title: "请先解析视频"
            });
        } else wx.showToast({
            title: "请先解析视频"
        });
    },
    bindDownloadImage: function(a) {
        var e = this;
        if (null != e.data.parseVideoResult) {
            var t = e.data.parseVideoResult.coverURL;
            null == t ? wx.showToast({
                title: "请先解析视频"
            }) : i.albumPermissionCheck(function() {
                e.downloadImage(t);
            }, e.data.permissionText);
        } else wx.showToast({
            title: "请先解析视频"
        });
    },
    bindVideoClear: function(a) {
        this.setData({
            inputVideoTxt: "",
            parseVideoUrl: "",
            parseVideoResult: null,
            videoPlayURL: null,
            resultUIDict: null
        });
    },
    bindMusicClear: function(a) {
        this.setData({
            inputMusicTxt: "",
            parseMusicResult: null,
            resultUIDict: null
        });
    },
    bindDownloadMP3: function(a) {
        console.log(a);
        var e = a.target.dataset.text;
        null != e && "" != e ? (console.log(t.globalData.systemInfo.platform), wx.showModal({
            title: "注意",
            content: "因为设备限制，不能直接下载MP3到手机。请点击复制链接，在电脑浏览器打开，然后右键保存到电脑下载。",
            confirmText: "复制链接",
            cancelText: "取消",
            success: function(a) {
                a.confirm ? wx.setClipboardData({
                    data: e,
                    success: function(a) {
                        wx.showToast({
                            title: "复制成功"
                        });
                    }
                }) : a.cancel && console.log("用户点击取消");
            }
        })) : wx.showToast({
            title: "请先解析视频"
        });
    },
    downloadMP3: function(a) {
        var e = this;
        if (null != a) {
            e.setData({
                downloadMP3Disabled: !0
            });
            a = e.getHost(1) + "pksr?s=" + encodeURIComponent(a);
            e.downloadTask = wx.downloadFile({
                url: a,
                header: i.buildHeader({}),
                success: function(a) {
                    if (200 === a.statusCode) {
                        e.setData({
                            copyMusicLinkText: "保存中"
                        }), e.setData({
                            tempVideoFilePath: a.tempFilePath
                        });
                        var o = a.tempFilePath;
                        console.log(o), wx.saveFile({
                            tempFilePath: o,
                            success: function(a) {
                                var o = a.savedFilePath;
                                console.log(o);
                                var s = e.data.aSTips;
                                "ios" == t.globalData.systemInfo.platform && (s = e.data.iSTips), wx.showModal({
                                    showCancel: !1,
                                    title: "保存成功",
                                    content: s
                                });
                            },
                            fail: function(a) {
                                wx.showToast({
                                    title: "保存失败"
                                }), e.setData({
                                    copyMusicLinkText: "下载背景音",
                                    downloadMP3Disabled: !1
                                });
                            }
                        });
                    } else wx.showModal({
                        title: "下载失败",
                        content: e.data.downloadErrorMsg
                    });
                },
                fail: function(t) {
                    t.errMsg;
                    wx.reportAnalytics("download_fail", {
                        link: a,
                        source_link: e.data.parseVideoUrl
                    }), wx.showModal({
                        title: "下载失败",
                        content: e.data.downloadErrorMsg
                    });
                },
                complete: function() {
                    e.downloadTask = null, e.setData({
                        loading: !1
                    }), e.setData({
                        copyMusicLinkText: "下载背景音",
                        downloadMP3Disabled: !1
                    });
                }
            }), e.downloadTask.onProgressUpdate(function(a) {
                e.setData({
                    progress: Math.round(100 * a.progress)
                }), e.setData({
                    copyMusicLinkText: "下载中：" + a.progress + "%"
                });
            });
        } else wx.showToast({
            title: "链接错误"
        });
    },
    bindCopyText: function(a) {
        console.log(a);
        var e = a.target.dataset.text;
        null != e && "" != e ? wx.setClipboardData({
            data: e,
            success: function(a) {
                wx.showToast({
                    title: "复制成功"
                });
            }
        }) : wx.showToast({
            title: "请先解析视频"
        });
    },
    bindMusicParse: function(a) {
        0 != i.canMake("ExpiredTime") || 1 != this.data.openShareLimit ? null != this.data.parseMusicQueryUrl && "" != this.data.parseMusicQueryUrl ? this.parseMusic() : wx.showToast({
            title: "请输入链接"
        }) : this.showShareTips();
    },
    parseMusic: function() {
        var a = this;
        if (wx.reportAnalytics("parse", {
            platform: "douyin"
        }), null != a.data.parseMusicQueryUrl && "" != a.data.parseMusicQueryUrl) if (1 != a.data.isLoading) {
            var e = {
                sourceURL: a.data.parseMusicQueryUrl
            };
            a.setData({
                parseMusicBtnText: "解析中",
                isLoading: !0
            }), o.getVideoDetailInfo(e, function(e) {
                if (a.setData({
                    parseMusicBtnText: "解析",
                    isLoading: !1
                }), console.log(e), console.log(e.errorMessage), 1010 == e.status && (wx.setStorageSync(i.getAuthTokenKey(), ""), 
                wx.setStorageSync("App", t.globalData.appName), t.login()), 0 == e.status) {
                    var o = e.data, s = [ {
                        title: "源链接",
                        desc: o.share_url
                    }, {
                        title: "点赞数",
                        desc: o.digg_count
                    }, {
                        title: "评论数",
                        desc: o.comment_count
                    }, {
                        title: "分享数",
                        desc: o.share_count
                    }, {
                        title: "描述",
                        desc: o.desc
                    }, {
                        title: "视频ID",
                        desc: o.videoID
                    }, {
                        title: "视频链接(带水印)",
                        desc: o.video_url
                    }, {
                        title: "封面链接",
                        desc: o.cover_url
                    }, {
                        title: "音乐链接",
                        desc: o.musicURL
                    } ];
                    a.setData({
                        parseMusicResult: o,
                        resultUIDict: s
                    }), n({
                        content: "解析成功",
                        mask: !1
                    });
                } else if (null != e.errorMessage) {
                    "model" == e.errorAlertType ? wx.showModal({
                        title: "提示",
                        content: e.errorMessage
                    }) : wx.showToast({
                        title: e.errorMessage
                    });
                } else wx.showToast({
                    title: "解析失败"
                });
            }, function(e) {
                a.setData({
                    parseBtnText: "解析",
                    isLoading: !1
                });
            });
        } else wx.showToast({
            title: "正在处理中"
        }); else wx.showToast({
            title: "请输入链接"
        });
    },
    bindTapQuery: function(a) {
        if (wx.reportAnalytics("parse", {
            platform: "douyin"
        }), 0 != i.canMake("ExpiredTime") || 1 != this.data.openShareLimit) if (null != this.data.parseQueryUrl && "" != this.data.parseQueryUrl) if (1 != this.data.isLoading) {
            this.data.parseQueryUrl;
            this.setData({
                queryBtnText: "查询中",
                isLoading: !0
            });
        } else wx.showToast({
            title: "正在处理中"
        }); else wx.showToast({
            title: "请输入链接"
        }); else this.showShareTips();
    },
    bindQueryClear: function(a) {
        this.setData({
            inputQueryTxt: "",
            queryUserResult: null,
            resultUIDict: null
        });
    },
    bindTapSubscription: function(a) {
        wx.setClipboardData({
            data: "西瓜工具",
            success: function(a) {
                wx.showToast({
                    title: "公众号复制成功"
                });
            }
        });
    },
    bindTapWeb: function(a) {
        wx.setClipboardData({
            data: "",
            success: function(a) {
                wx.showToast({
                    title: "官网复制成功"
                });
            }
        });
    },
    bindTapHelp: function(a) {
        wx.navigateTo({
            url: "/pages/help/help"
        });
    },
    bindTapAD: function(a) {
        wx.navigateToMiniProgram({
            appId: this.data.adAppID,
            path: this.data.adBannerPath,
            extraData: {
                foo: "bar"
            },
            envVersion: "release",
            success: function(a) {}
        });
    },
    bindTapBanner: function(a) {
        wx.navigateToMiniProgram({
          appId: 'wx6820760b1be48361',
        })
    },
    modalConfirm: function() {
        console.log("modalConfirm"), this.setData({
            showModal: !1,
            showDownloadProgressModel: !1
        });
    },
    parseVideo: function() {
        var a = this;
        console.log(e, a.data.dyPHost,11111)
        if (wx.reportAnalytics("parse", {
            platform: "douyin"
        }), null != a.data.parseVideoUrl && "" != a.data.parseVideoUrl) if (1 != a.data.isLoading) {
            var e = {
                sourceURL: a.data.parseVideoUrl
            };
            a.setData({
                parseBtnText: "解析中",
                isLoading: !0
            })
            wx.request({
              url: 'https://guanhe.work/xiaochengxu/getUrl?url='+getUrl(e.sourceURL),
              success(e){
                e=e.data
                console.log('success',e)
                a.setData({
                    parseBtnText: "解析",
                    isLoading: !1
                })
                if (e.mp4) {
                    console.log(11112222222)
                    let ParseCount = wx.getStorageSync('ParseCount')
                    if(!wx.getStorageSync('ParseCount')){
                        wx.setStorageSync('ParseCount', 1)
                    } else {
                        wx.setStorageSync('ParseCount', wx.getStorageSync('ParseCount')/1+1)
                    }
                    
                    wx.setStorageSync('parseData', e)
                    wx.navigateTo({
                        url:'/pages/download/download'
                    })
                } else {
                    wx.showModal({
                        title: "提示",
                        content: a.data.errorTips
                    });
                }
              },
              fail(e){
                wx.reportAnalytics("parse_fail", {
                    source_link: a.data.parseVideoUrl
                }), a.setData({
                    parseBtnText: "解析",
                    isLoading: !1
                });
              }
            })
        } else wx.showToast({
            title: "正在处理中"
        }); else wx.showToast({
            title: "请输入视频链接"
        });
    },
    getHost: function(a) {
        var e = wx.getStorageSync("appConfig"), o = 10;
        null != e && e.hwks1 && (o = e.hwks1);
        var s = 0;
        null != e && e.hwks2 && (s = e.hwks2);
        var n = 0;
        null != e && e.hwks3 && (n = e.hwks3);
        var d = t.globalData.dHost;
        null != e && e.hostks1 && (d = e.hostks1);
        var l = t.globalData.dHost;
        null != e && e.hostks2 && (l = e.hostks2);
        var r = t.globalData.dHost;
        null != e && e.hostks3 && (r = e.hostks3);
        var u = [ {
            host: d,
            weight: o
        }, {
            host: l,
            weight: s
        }, {
            host: r,
            weight: n
        } ], p = d, h = i.weightRand(u);
        return console.log("result host:" + h), h && null != h && (p = h), 1 != a && (p = d), 
        -1 != p.indexOf(l) ? this.setData({
            hostFlag: "2"
        }) : -1 != p.indexOf(r) ? this.setData({
            hostFlag: "3"
        }) : this.setData({
            hostFlag: "1"
        }), p;
    },
    downloadVideo: function(a, e) {
        var o = this;
        wx.reportAnalytics("download", {
            platform: "douyin"
        });
        var s = o.getHost(e) + "pksr?s=temp.mp4", n = "下载中";
        n = 1 == e ? "下载中" : "正在重试...", o.setData({
            showDownloadProgressModel: !0,
            downloadVideoBtnText: n,
            downloadVideoDisabled: !0
        });
        var d = {
            ssu: a
        };
        console.log(s), o.downloadTask = wx.downloadFile({
            url: 'http://192.168.143.36/download?url=https://aweme.snssdk.com/aweme/v1/play/?video_id=v0d00fg10000cc24ogjc77u23gbhde0g&ratio=720p&line=0',
            success: function(i) {
                200 === i.statusCode ? (o.setData({
                    downloadVideoBtnText: "保存中"
                }), o.setData({
                    tempVideoFilePath: i.tempFilePath
                }), console.log(i.tempFilePath), wx.saveVideoToPhotosAlbum({
                    filePath: i.tempFilePath,
                    success: function(a) {
                        if (console.log(a), o.setData({
                            showDownloadProgressModel: !1
                        }), -1 != o.data.adBannerType && 1 == o.data.showAlertAD) o.setData({
                            downloadVideoBtnText: "下载无水印视频",
                            downloadVideoDisabled: !1,
                            showModal: !0
                        }); else {
                            var e = o.data.aSTips;
                            "ios" == t.globalData.systemInfo.platform && (e = o.data.iSTips), wx.showModal({
                                showCancel: !1,
                                title: "保存成功",
                                content: e
                            });
                        }
                        console.log(a.errMsg);
                    },
                    fail: function(a) {
                        wx.showToast({
                            title: "保存失败"
                        }), o.setData({
                            showDownloadProgressModel: !1,
                            downloadVideoBtnText: "下载无水印视频",
                            downloadVideoDisabled: !1
                        });
                    }
                })) : (wx.reportAnalytics("download_fail", {
                    link: s,
                    source_link: o.data.parseVideoUrl
                }), 1 == e ? (console.log("重试"), o.setData({
                    downloadVideoBtnText: "正在重试...",
                    downloadVideoDisabled: !0
                }), o.downloadVideo(a, e + 1)) : (o.setData({
                    showDownloadProgressModel: !1
                }), wx.showModal({
                    title: "下载失败",
                    content: o.data.downloadErrorMsg
                })));
            },
            fail: function(t) {
                t.errMsg;
                1 == e ? (console.log("重试"), o.setData({
                    downloadVideoBtnText: "正在重试...",
                    downloadVideoDisabled: !0
                }), o.downloadVideo(a, e + 1)) : (o.setData({
                    showDownloadProgressModel: !1
                }), wx.showModal({
                    title: "下载失败",
                    content: o.data.downloadErrorMsg
                }));
            },
            complete: function() {
                "正在重试..." == o.data.downloadVideoBtnText && 1 == e || (o.downloadTask = null, o.setData({
                    loading: !1
                }), o.setData({
                    showDownloadProgressModel: !1,
                    downloadVideoBtnText: "下载无水印视频",
                    downloadVideoDisabled: !1
                }));
            }
        }), o.downloadTask.onProgressUpdate(function(a) {
            o.setData({
                progress: Math.round(100 * a.progress)
            }), o.setData({
                downloadVideoBtnText: "下载中：" + a.progress + "%"
            });
        });
    },
    downloadVideoV2: function(a) {
        var e = this;
        null != a ? (e.setData({
            downloadVideoDisabled: !0
        }), e.downloadTask = wx.downloadFile({
            url: a,
            success: function(a) {
                200 === a.statusCode ? (e.setData({
                    downloadVideoBtnText: "保存中"
                }), e.setData({
                    tempVideoFilePath: a.tempFilePath
                }), console.log(a.tempFilePath), wx.saveVideoToPhotosAlbum({
                    filePath: a.tempFilePath,
                    success: function(a) {
                        if (-1 != e.data.adBannerType && 1 == e.data.showAlertAD) e.setData({
                            downloadVideoBtnText: "下载无水印视频",
                            downloadVideoDisabled: !1,
                            showModal: !0
                        }); else {
                            var o = e.data.aSTips;
                            "ios" == t.globalData.systemInfo.platform && (o = e.data.iSTips), wx.showModal({
                                showCancel: !1,
                                title: "保存成功",
                                content: o
                            });
                        }
                        console.log(a.errMsg);
                    },
                    fail: function(a) {
                        wx.showToast({
                            title: "保存失败"
                        }), e.setData({
                            downloadVideoBtnText: "下载无水印视频",
                            downloadVideoDisabled: !1
                        });
                    }
                })) : wx.showModal({
                    title: "下载失败",
                    content: e.data.downloadErrorMsg
                });
            },
            fail: function(t) {
                t.errMsg;
                wx.reportAnalytics("download_fail", {
                    link: a,
                    source_link: e.data.parseVideoUrl
                }), wx.showModal({
                    title: "下载失败",
                    content: e.data.downloadErrorMsg
                });
            },
            complete: function() {
                e.downloadTask = null, e.setData({
                    loading: !1
                }), e.setData({
                    downloadVideoBtnText: "下载无水印视频",
                    downloadVideoDisabled: !1
                });
            }
        }), e.downloadTask.onProgressUpdate(function(a) {
            e.setData({
                progress: Math.round(100 * a.progress)
            }), e.setData({
                downloadVideoBtnText: "下载中：" + a.progress + "%"
            });
        })) : wx.showToast({
            title: "链接错误"
        });
    },
    downloadImage: function(a) {
        var e = this;
        "https://" == a.substring(0, 8) || (a = a.replace("http://", "https://")), e.setData({
            downloadImageBtnText: "下载中",
            downloadImageDisabled: !0
        });
        a = e.getHost(1) + "pksri?s=" + encodeURIComponent(a);
        e.downloadTask = wx.downloadFile({
            url: a,
            header: i.buildHeader({}),
            success: function(a) {
                e.setData({
                    downloadImageBtnText: "保存中"
                }), e.setData({
                    tempImageFilePath: a.tempFilePath
                }), console.log(a.tempFilePath), wx.saveImageToPhotosAlbum({
                    filePath: a.tempFilePath,
                    success: function(a) {
                        e.setData({
                            downloadImageBtnText: "下载视频封面",
                            downloadImageDisabled: !1
                        }), console.log(a.errMsg);
                        var o = e.data.aSTips;
                        "ios" == t.globalData.systemInfo.platform && (o = e.data.iSTips), wx.showModal({
                            showCancel: !1,
                            title: "保存成功",
                            content: o
                        });
                    },
                    fail: function(a) {
                        wx.showToast({
                            title: "保存失败"
                        }), e.setData({
                            downloadImageBtnText: "下载视频封面",
                            downloadImageDisabled: !1
                        });
                    }
                });
            },
            fail: function(a) {
                a.errMsg;
                wx.showToast({
                    title: "下载失败"
                });
            },
            complete: function() {
                e.downloadTask = null, e.setData({
                    loading: !1
                }), e.setData({
                    downloadImageBtnText: "下载视频封面",
                    downloadImageDisabled: !1
                });
            }
        }), e.downloadTask.onProgressUpdate(function(a) {
            e.setData({
                progress: Math.round(100 * a.progress)
            }), e.setData({
                downloadImageBtnText: "下载中：" + a.progress + "%"
            });
        });
    },
    downloadShareImage: function(a) {
         wx.saveImageToPhotosAlbum({
                    filePath: '/images/share.jpg',
                    success: function(a) {
                        wx.showToast({
                            title: "保存到相册成功"
                        });
                    },
                    fail: function(a) {
                        wx.showToast({
                            title: "保存失败"
                        });
                    }
                })
    },
    tapTutorial: function(a) {
        wx.navigateTo({
            url: "/pages/tutorialImages/tutorialImages"
        });
    },
    showShareTips: function() {
        this.selectComponent("#dialog").showDialog();
    },
    showRewardedVideoAdTips: function() {
        var a = this;
        wx.showModal({
            title: "提示",
            confirmText: "看广告",
            cancelText: "取消",
            content: a.data.rewardedVideoAdTips,
            success: function(e) {
                e.confirm ? a.showRewardedVideoAd() : e.cancel && console.log("用户点击取消");
            }
        });
    },
    showRewardedVideoAd: function() {
        var a = this.data.rewardedVideoAd;
        a.show().catch(function(e) {
            a.load().then(function() {
                return a.show();
            });
        });
    },
    _cancelEvent: function() {
        console.log("你点击了取消"), this.selectComponent("#dialog").hideDialog();
    },
    _confirmEvent: function() {
        console.log("你点击了确定"), this.selectComponent("#dialog").hideDialog();
    },
    toHome: function(a) {
        1 == this.data.isShare ? (wx.reLaunch({
            url: "/pages/home/home"
        }), wx.navigateBack({})) : wx.navigateBack({});
    },
    toImageDetail: function() {
        var a = this.data.parseVideoResult;
        console.log("toImageDetail"), console.log(a), "image" == a.type ? (wx.setStorageSync("ImagesTemp", JSON.stringify(a)), 
        wx.navigateTo({
            url: "/pages/imageDetail/imageDetail?title=快首图集"
        })) : wx.showToast({
            title: "没有图集"
        });
    },
    kindToggle: function(a) {
        for (var e = a.currentTarget.id, t = this.data.list, o = 0, s = t.length; o < s; ++o) t[o].id == e ? t[o].open = !t[o].open : t[o].open = !1;
        this.setData({
            list: t
        });
    },
    toChild: function(a) {
        a.currentTarget.dataset.index;
        var e = a.currentTarget.dataset.url;
        console.log(e), wx.navigateTo({
            url: e
        });
    },
    clickCloseHover: function(a) {
        this.setData({
            showHover: !1
        });
    },
    clickHoverItem: function(a) {
        console.log("clickhoverItem");
        var e = this.data.hover;
        i.forwardItem(e);
    }
});